#ifndef TC_ENDIAN_HH
#define TC_ENDIAN_HH

/** \file Endian.hh 
 * The big or little endian-ness related functions.
 *
 * (C) Copyright  Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: Endian.hh 117 2006-06-19 06:49:41Z semihc $
 *
 *
 */

#include "Global.hh"


namespace TC {


  /**
   * Determine if the CPU architecture is little endian.
   * That is least significant byte is stored first:
   * 0xabcd is stored as 0xcdab in memory.
   */
  bool LittleEndian();

  /**
   * Determine if the CPU architecture is big endian.
   * That is most significant byte is stored first:
   * 0xabcd is stored as 0xabcd in memory.
   */
  inline bool BigEndian() { return !LittleEndian(); }

  /**
   * Swap bytes of a wide character.
   */
  inline wchar_t Swap(wchar_t val)
  {
    return (((val>>8) & 0x00ff) | ((val<<8) & 0xff00));
  }


} // end namespace

#endif /* TC_ENDIAN_HH */
